{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fuzzywuzzy import fuzz\n",
    "from fuzzywuzzy import process"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fuzz.partial_ratio(\"this is a te\", \"this is a test!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n"
     ]
    }
   ],
   "source": [
    "ceo_names = ['ya lv', 'alex guan wang', 'crown \"Crowy\" guan wang']                                                                                                                               \n",
    "result = process.extractOne(\"crown guan wang\", ceo_names, scorer=fuzz.token_set_ratio)\n",
    "print result[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "from cfuzzyset import cFuzzySet as FuzzySet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = FuzzySet()\n",
    "a.add(\"Akinlola 'Akin Ire' Olopade\")\n",
    "#a.add(\"micael abiak\")\n",
    "result = a.get(\"Akin Ire Olopade\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(0.625, u'Akinlola Olopade')\n"
     ]
    }
   ],
   "source": [
    "print result[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Akinlola Olopad\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "myString = 'Akinlola \"Akin Ire\" Olopade'\n",
    "#myString.find('\"')\n",
    "todel = [ i.start() for i in re.finditer('\"', myString)]\n",
    "if len(todel) == 2:\n",
    "    myString = myString[0:todel[0]] + myString[todel[1]+2:-1]\n",
    "print myString"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import nlyk"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
